package thread;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockTest extends Thread {
    static  int a = 0;
     static ReentrantLock reentrantLock = new ReentrantLock();
    public static void main(String[] args) throws InterruptedException {
        ReentrantLockTest reentrantLockTest = new ReentrantLockTest();
        ReentrantLockTest reentrantLockTest1 = new ReentrantLockTest();
        reentrantLockTest.start();
        reentrantLockTest1.start();
        reentrantLockTest.join();
        reentrantLockTest1.join();
        System.out.println(a);
    }
    @Override
    public void run() {
        reentrantLock.lock();
        for (int i = 0;i<10000;i++){
            a++;
        }
        reentrantLock.unlock();
    }
}
